<!--
 * @Author: your name
 * @Date: 2021-09-06 09:12:00
 * @LastEditTime: 2021-09-06 15:59:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day11\DOM.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="myDiv">
        <div id="div1">text</div>
        <div id="div2">text</div>
    </div>

</body>
<script>
    var myDiv = document.getElementById('myDiv');
    console.log(myDiv);
    var div1 = document.getElementById('div1');
    console.log(div1);

    //创建一个LI节点
    var node = document.createElement("LI");
    //创建一个text节点
    var textNode = document.createTextNode("hello");
    //将text节点追加到LI节点上
    node.appendChild(textNode);
    //找到id为myDiv的节点
    document.getElementById("myDiv");
    //将刚刚创建的node节点追加为myDiv的子节点
    myDiv.appendChild(node);
</script>

</html>